<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<style type="text/css">
.selected {
	visibility: hidden;
}
</style>
		<script type="text/javascript">
			$(function() {
				$(".date").datepicker({
					showWeek : true,
					firstDay : 1,
					dateFormat : 'yy-mm-dd',
					showOtherMonths : true,
					selectOtherMonths : true
				});
				$("#datepicker").datepicker({
					showWeek : true,
					firstDay : 1,
					dateFormat : 'yy-mm-dd',
					showOtherMonths : true,
					selectOtherMonths : true,
					onSelect : function(date, source) {
						$("form").submit();
					}
				});
			});
		</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<form class="form-horizontal">
			<fieldset>
				<legend>课表管理</legend>
				<div class="control-group">
					<label class="control-label">时间范围</label>
					<div class="controls">
						<div class="form-inline">
							<input type="text" class="date input-small" name="startDate" value="${param.startDate}" />~<input type="text" class="date input-small" name="endDate"
								value="${param.endDate}" />
							<label class="checkbox">
								<input type="checkbox" name="canceled" value="true" <s:if test='"true" in #parameters.canceled'>checked="checked"</s:if> />已取消
							</label>
							<label class="checkbox">
								<input type="checkbox" name="canceled" value="false" <s:if test='"false" in #parameters.canceled'>checked="checked"</s:if> />正常
							</label>
							<button class="btn btn-primary" type="submit">查询</button>
						</div>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">教员</label>
					<div class="controls">
						<div class="form-inline">
							<s:iterator value="#teachers" var="teacher">
								<label class="checkbox">
									<input type="checkbox" name="teacher" value="${teacher.id}" <s:if test='id in #parameters.teacher'>checked="checked"</s:if> />${teacher.name}
								</label>
							</s:iterator>
						</div>
					</div>
				</div>
			</fieldset>
		</form>
		<div>每页${lessons.size}项，共 ${lessons.totalElements} 项，当前${lessons.number+1}/ ${lessons.totalPages}页</div>
		<table class="table">
			<thead>
				<tr>
					<th>Day</th>
					<th>Time</th>
					<th>Lesson</th>
					<th>Teacher</th>
					<th>Classroom</th>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="lessons" var="lesson">
					<tr class="${lesson.courseType.cssClass}">
						<td><s:date name="beginTime" format="yyyy-MM-dd" id="beginTimeStr" /> <s:url action="listDailyLesson" namespace="/lesson" id="listDailyLesson">
								<s:param name="startDate" value="#beginTimeStr"></s:param>
							</s:url> <a href="${listDailyLesson}" title="当日课程">
								<s:property value="#beginTimeStr" />
							</a></td>
						<td>${lesson.timespan}</td>
						<td><s:url action="listListener" namespace="/lesson" id="listListener">
								<s:param name="id" value="id"></s:param>
							</s:url> <a href="${listListener}">${lesson.name}</a> <s:if test="#lesson.canceled">
								<span class="label">已取消</span>
							</s:if></td>
						<td><s:iterator value="teachings" var="teaching" status="status">
								<s:url action="listLesson" namespace="/lesson" id="listLesson">
									<s:param name="teacher" value="teacher.id"></s:param>
									<s:param name="startDate" value="#parameters.startDate"></s:param>
									<s:param name="endDate" value="#parameters.endDate"></s:param>
								</s:url>
								<a href="${listLesson}">${teaching.teacher.name} </a>
								<s:if test="!status.last">,</s:if>
							</s:iterator></td>
						<td>${lesson.classroom.name}</td>
					</tr>
				</s:iterator>
			</tbody>
			<tfoot></tfoot>
		</table>
		<jsp:include page="/components/pagination/paginations.jsp"></jsp:include>
	</tiles:putAttribute>
</tiles:insertDefinition>